home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / MouseInfo 1.0.1 / UMouseInfo.cp < prev    next >
Encoding:
Text File  |  1992-07-15  |  1.9 KB  |  83 lines  |  [TEXT/MPS ]

  1. //     UMouseInfo.cp 
  2. //     Copyright © 1992 by Apple Computer, Inc. All rights reserved.
  3. //    Kent Sandvik DTS
  4. //    This file contains the basic TMapApplication member functions
  5. //    Version Info (latest first):
  6. //
  7. //    <1>        khs        1.0        First final version
  8. //    <2>        khs        1.0.1    Fixed a memory leak in TMapApplication::GetSleepValue()
  9.  
  10.  
  11. // INCLUDES 
  12.  
  13. #ifndef __MOUSEINFO__
  14. #include "UMouseInfo.h"                                        // class definitions
  15. #endif
  16.  
  17. extern RgnHandle gtempRgn;
  18.  
  19.  
  20. //    Empty constructor - for avoiding ptabs in global data space
  21. #pragma segment ARes
  22. TMapApplication::TMapApplication()
  23. {
  24. }
  25.  
  26.  
  27. //    Initialize the Application object
  28. #pragma segment AInit
  29. pascal void TMapApplication::IMapApplication(OSType fileType,
  30.                                              OSType creator)
  31. {
  32.     inherited::IApplication(fileType, creator);
  33.  
  34.     if (gDeadStripSuppression)
  35.         macroDontDeadStrip(TAppFrameAdorner);
  36.  
  37.     RegisterStdType("TAppFrameAdorner", 'afra');// register adorner types
  38. }
  39.  
  40.  
  41. //    Create a new TDocument from the class
  42. #pragma segment AOpen
  43. pascal TDocument* TMapApplication::DoMakeDocument(CommandNumber/* itsCmdNumber */,
  44.                                                   TFile*/* itsFile */ )
  45. {
  46.     TMouseDocument * aMouseDocument = new TMouseDocument;
  47.     aMouseDocument->IMouseDocument();
  48.     return aMouseDocument;
  49. }
  50.  
  51.  
  52. // Show our cute About Box with Jeff trying to destroy my portable at Bahia Honda
  53. #pragma segment AMain
  54. pascal void TMapApplication::DoAboutBox()
  55. {
  56.     CreateAboutBox();
  57. }
  58.  
  59.  
  60. //    Make sleep region small so we will get more mouse events, make this
  61. //    dynamic so we could turn this on off depending if the mouse tracking behavior is active
  62. #pragma segment MAApplicationRes
  63. pascal RgnHandle TMapApplication::GetSleepRegion()
  64. {
  65.     if (gMouseTrackWindow)                        // we have a floating window tracking mouse movements -> more events needed
  66.     {
  67.         CPoint mousePoint;
  68.  
  69.         GetMouse(mousePoint);
  70.         SetRectRgn(gtempRgn, mousePoint.v, mousePoint.h, mousePoint.v + 1, mousePoint.h + 1);
  71.  
  72.         return gtempRgn;
  73.     }
  74.     else
  75.         return inherited::GetSleepRegion();
  76. }
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.